<?php

namespace App\Models;

use App\Services\Product\ExcelService;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class RefundAfterSaleManagement extends Model{
    
    //退款售后管理
    protected $table = 'refund_after_sale_managements';

    public $timestamps = false;

    protected $fillable = [
        //订单编号
        'order_num',
        //退款编号
        'refund_num',
        //支付宝交易号
        'alipay_trade_num',
        //买家会员名称
        'buyer_member_name',
        //总金额
        'total_money',
        //买家实际支付金额
        'buyer_actually_pay_money',
        //宝贝标题
        'commodity_title',
        //买家退款金额
        'buyer_refund_money',
        //部分退款/全额退款
        'is_total_refund',
        //手工退款/系统退款
        'refund_way',
        //是否需要退货
        'is_need_sales_return',
        //退款的申请时间
        'refund_applied_at',
        //超时时间
        'overtime_at',
        //退款状态
        'refund_status',
        //货物状态
        'commodity_status',
        //客服介入状态
        'service_intervene_status',
        //卖家内部处理人员
        'seller_internal_operator',
        //卖家真实姓名
        'seller_true_name',
        //卖家退货地址
        'seller_address_for_return_delivery',
        //卖家邮编
        'seller_postcode',
        //卖家电话
        'seller_phone',
        //卖家手机
        'seller_mobile',
        //退货物流类型
        'logistics_num',
        //退货物流公司
        'logistics_company',
        //退货订单号
        'sales_return_order_num',
        //买家退款原因
        'buyer_refund_reason',
        //买家退款说明
        'buyer_refund_state',
        //买家退货时间
        'buyer_returns_at',
        //售中或售后
        'after_sale',
        //责任方
        'responsible_party',
        //完结时间（天）
        'finsh_time',
        //是否零秒响应
        'is_respond_immediately',
    ];

    public function setRefundAppliedAtAttribute($value){
        $value = (new ExcelService)->setColumnValueToDateString($value);
        $this->attributes['refund_applied_at'] = $value;
    }

    public function setOvertimeAtAttribute($value){
        $value = (new ExcelService)->setColumnValueToDateString($value);
        $this->attributes['overtime_at'] = $value;
    }

}
